import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

typedef valueCallBack = Function(dynamic type);

class SelectCircleWidget extends StatefulWidget {
  bool isSelect;
  bool canOnTap;
  valueCallBack callBack;
  double size;
  Color? selectColor;
  double radius;

  SelectCircleWidget({
    this.isSelect: false,
    required this.callBack,
    this.size: 20,
    this.selectColor,
    this.canOnTap: true,
    this.radius: 50,
  });

  @override
  _SelectCircleWidgetState createState() => _SelectCircleWidgetState();
}

class _SelectCircleWidgetState extends State<SelectCircleWidget> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        width: widget.size.w,
        height: widget.size.w,
        alignment: Alignment.center,
        child: Icon(
          Icons.check,
          color: widget.isSelect ? Colors.white : Colors.transparent,
          size: 15.w,
        ),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(widget.radius),
            color: widget.isSelect
                ? widget.selectColor ?? Color(0xFFFEBA07)
                : widget.canOnTap
                    ? Colors.white
                    : Colors.grey[200],
            border: Border.all(
                width: 1,
                color:
                    widget.isSelect ? Colors.transparent : Color(0xFF979797))),
      ),
      onTap: () {
        if (widget.canOnTap) {
          setState(() {
            widget.isSelect = !widget.isSelect;
            widget.callBack(widget.isSelect);
          });
        }
      },
    );
  }
}
